let scroll = {}
scroll.code = `
<template>
  <Scroll :height="scrollConentHeight" :on-reach-bottom="scrollMore" :distance-to-edge="5">
    <template v-for="content in infiniteScrollContent">
      <Alert :type="content.type" show-icon :key="content.id">
        {{content.title}}
        <Icon :type="content.icon" v-if="content.icon" slot="icon" />
        <span slot="desc">{{content.desc}}</span>
      </Alert>
    </template>
  </Scroll>
</template>
<script>
export default {
  data: () => {
    return {
      infiniteScrollContent: [
        { id: 1, desc: 'fasd ag dapianzi carl ', title: 'You shall not pass', type: 'error' },
        { id: 1, desc: 'We don\\'t talk any more ', title: 'Mary lives downstairs', type: 'info' },
        { id: 1, desc: 'Why do all good things come to an end ', title: 'Sometime sadness', type: 'success' },
        { id: 1, desc: '总会有一些 善良的狗 心中藏着秘密 ', title: '北方的女王', type: 'warning' },
        { id: 1, desc: 'Don\\'t make me sad, don\\'t make me sade', title: 'Born to die', type: 'success', icon: 'ios-planet-outline' }
      ],
      scrollConentHeight: '100%'
    }
  },
  computed: {
    scrollLastId () {
      return this.infiniteScrollContent.length > 0
        ? this.infiniteScrollContent[this.infiniteScrollContent.length - 1].id
        : 0
    }
  },
  methods: {
    scrollMore () {
      console.log('scroll more..')
      return new Promise((resolve, reject) => {
        this.$axios.get('http://test.th6188.com/test/mock?action=scroll&id=' + this.scrollLastId).then(res => {
          if (res.data.code) {
            reject(new Error(res.data.msg))
          } else {
            this.infiniteScrollContent = this.infiniteScrollContent.concat(res.data.data)
            resolve()
          }
        })
      })
    }
  },
  mounted () {
    this.render()
    this.mockTableData(0)
    this.$nextTick(() => {
      // 等其他组件处理完高度，再计算赋值
      this.scrollConentHeight = this.$parent.$el.clientHeight
    })
  }
}
</script>
`
export default scroll
